package eclipse.weibo;

public class WOWShenFenID {
    public static void main(String[] ss) {
        System.out.println(isIdCard("422302196601270070"));
    }

    public static boolean isIdCard(String arrIdCard) {
        int sigma = 0;
        Integer[] a = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
        String[] w = { "1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2" };
        for (int i = 0; i < 17; i++) {
            int ai = Integer.parseInt(arrIdCard.substring(i, i + 1));
            int wi = a[i];
            sigma += ai * wi;
        }
        int number = sigma % 11;
        String check_number = w[number];
        //return check_number;
        System.out.println(check_number);
        if (!arrIdCard.substring(17).equals(check_number)) {
            return false;
        } else {
            return true;
        }
    }
}
